package com.bilgeadam.hibernate.program;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

/**
 * 
 * @author Bora SAYINER
 * @since Nov 15, 2014 3:57:55 PM
 * @version 1.0.0
 */
public class Driver {

	public static void main(String[] args) {
		SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
		Session session = sessionFactory.openSession();
		Transaction transaction = session.beginTransaction();
		{
			Vehicle vehicle = new Vehicle();
			vehicle.setName("Car");
			session.save(vehicle);

			TwoWheeler bike = new TwoWheeler();
			bike.setName("Bicycle");
			bike.setSteeringHandle("Steering handle...");
			session.save(bike);

			FourWheeler porsche = new FourWheeler();
			porsche.setName("Porsche");
			porsche.setSteeringWheel("Steering wheels...");
			session.save(porsche);
		}
		transaction.commit();
		session.close();
		sessionFactory.close();
	}
}
